home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / uwserver.zip / uwserver.tar / h / uw_clk.h < prev    next >
C/C++ Source or Header  |  1991-01-25  |  1KB  |  41 lines

  1. /*
  2.  *    uw_clk - timer support for UW
  3.  *
  4.  * Copyright 1986 by John D. Bruner.  All rights reserved.  Permission to
  5.  * copy this program is given provided that the copy is not sold and that
  6.  * this copyright notice is included.
  7.  */
  8.  
  9. #ifndef UW_CLK
  10. #define    UW_CLK
  11.  
  12. /*
  13.  * Events which are supposed to occur at a certain time are handled by
  14.  * setting "timeout"s.  The list of timeouts is sorted in order of
  15.  * occurrence.  The "alarm" mechanism is used to send SIGALRM when the
  16.  * first timeout expires.  However, the timeout is not processed
  17.  * immediately.  Instead, it will be processed upon exit from the
  18.  * select() in main().  This prevents timeouts from happening at
  19.  * inappropriate times.
  20.  *
  21.  * The resolution of timeouts is in seconds.  The server doesn't need
  22.  * any better resolution, and this allows all of the hair associated with
  23.  * (struct timeval) and (struct itimerval) types to be avoided.
  24.  */
  25.  
  26. #define    CLK_HZ        1        /* one tick/second */
  27.  
  28. typedef long toarg_t;
  29.  
  30. struct timeout {
  31.     struct timeout    *to_next;
  32.     time_t        to_when;
  33.     void        (*to_fn)();
  34.     toarg_t        to_arg;
  35. };
  36.  
  37. extern int timer_rdy;
  38.  
  39. #define    CLK_CHECK()    if (timer_rdy) clk_service(); else
  40. #endif
  41.